// ==UserScript==
// @name         my_Anti_debugger
// @namespace    http://tampermonkey.net/
// @version      v0.0.2-alpha
// @description  反调试脚本
// @author       zxywonder
// @include      *://*hisprice*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant        unsafeWindow
// @run-at       document-start
// @downloadURL https://gitee.com/zxywonder/js_script/blob/master/Anti_debugger.js
// @updateURL https://gitee.com/zxywonder/js_script/blob/master/Anti_debugger.js
// ==/UserScript==

(async function () {
    var setInterval_ = window.setInterval
    window.setInterval = function (func, timer) {
        if (func.toString().indexof('') === -1) {

        }
        else {
        }
    }
    window.setInterval.toString = function () {
        return "function setInterval(){ [native code] }"
    }

    var _constructor = unsafeWindow.Function.prototype.constructor;
    // Hook Function.prototype.constructor
    unsafeWindow.Function.prototype.constructor = function () {
        var fnContent = arguments[0];
        if (fnContent) {
            if (fnContent.includes('debugger')) { // An anti-debugger is attempting to stop debugging
                var caller = Function.prototype.constructor.caller; // Non-standard hack to get the function caller
                var callerContent = caller.toString();
                if (callerContent.includes(/\bdebugger\b/gi)) { // Eliminate all debugger statements from the caller, if any
                    callerContent = callerContent.replace(/\bdebugger\b/gi, ''); // Remove all debugger expressions
                    eval('caller = ' + callerContent); // Replace the function
                }
                return (function () { });
            }
        }
        // Execute the normal function constructor if nothing unusual is going on
        return _constructor.apply(this, arguments);
    };

    // 保存原始方法
    unsafeWindow.__cr_fun = unsafeWindow.Function;
    // 重写 function
    var myfun = function () {

        var args = Array.prototype.slice.call(arguments, 0, -1).join(","),
            src = arguments[arguments.length - 1];
        //console.log(src);
        return () => { }
        return unsafeWindow.__cr_fun.apply(this, arguments);
    }
    // 屏蔽js中对原生函数native属性的检测
    myfun.toString = function () {
        return unsafeWindow.__cr_fun + ""
    }
    Object.defineProperty(unsafeWindow, 'Function', {
        value: myfun
    });

    // Your code here...
})();